Let's go ahead and add a leaderboard to our game so we could see our stats and the stats of the other
people who are playing.
I'm going to do a leaderboard with three metrics I'm going to do kills deaths and points.
Right.
And the kills, I think I'll make it player versus player kills.
Not for NPCs, but you could easily modify that if you want.
Let's go to server script service, hit the plus, add a script and then I'm going to call this game
manager and sometimes I call it leaderboard.
It depends on how much I want to put in there, but I want to put saving the leaderboard too.
So that's what I'm going to call game manager.
I'm going to have more than just the leaderboard script in here.
Go ahead and delete that print statement right there.
And then we're going to add a function that adds a leaderboard to players as they enter the game.
So we'll say local function add board.
Right.
And a player is going to get passed in.
That's the player we're adding our board to.
All players are going to get a leaderboard.
Let's say local board equals instance Dot No.
We're going to make a new instance of a folder, a folder or a model you could do a model to and the
player is going to be the parent.
So the second argument is, the parent of what we're creating instance new is creating a new instance
of a new instance of a folder.
So board name must be equal to leader stats.
This has to be spelled right.
You have to have a lowercase l.
There can't be any variation or it's not going to work.
You won't get an error, it just won't work.
And then now we're going to put metrics on our leaderboard.
We're going to do points right instance new, and we're going to make a new instance of an int value.
INT value is for it.
Integer value.
One, two, three, four.
Right.
So we're not going to have decimal points, we're only going to have integer points and the parent is
going to be the board.
So we're putting the points on the board, we're putting the board on the player.
All right.
So now let's get our points, get a name for that.
Let's call that points.
This is what's going to be displayed in the header of the leaderboard in the game.
So spell it the way you want people to see it.
Now we'll do another metric for kills instance, new int value, and then board is going to be the parent.
Let's go ahead and do kills dot name equals kills and we want deaths to write local deaths equal instance,
new int value board and deaths.
We're going to give that a name dot name deaths.
Cool.
So we have kills deaths and points all in the board.
The board is on the player and the player is going to get this board added when we use this game dot
players services player added event.
Then we're going to connect that to our add board.
Get rid of those two extra parentheses when we captured an event and connect it to a function.
We're just going to use the name, not the, not the parentheses.
So the player added is going to know to pass a player in when you connect that function.
Pretty cool.
Let's go ahead and try it.
Every player that enters the game is going to get this because every time you enter the game, the player
added function is is fired.
Look at that points kills deaths.
We have a leaderboard.
Let's go ahead and in the next video we'll work on points.
Start populating that.